package com.xy.smartsms.db.carrierparam.entity;

import android.content.ContentValues;

/**
 * Created by admin on 2016/11/24.
 */

public class OnlineConfigItem {
    /* 功能开关 */
    public static final String KEY_SWITCH_BITWISE = "TOP_SWITCH_BITWISE";
    /* 第三方功能不完整时使能bitport开关 */
    public static final String KEY_RESULT_NULL_BITWISE = "RESULT_NULL_BITWISE";
    /* 逃生黑名单情景列表，以分号隔开，如: 01;02001;03000000 */
    public static final String KEY_BLACK_SCENE_LIST = "BLACK_LIST_SCENE";
    /* 配置表上次更新成功的更新周期 */
    public static final String KEY_PERIOD_CONFIG_SUCCESS = "PERIOD_ONLINE_CONFIG_SUCCESS";
    /* 配置表上次更新失败的更新周期 */
    public static final String KEY_PERIOD_CONFIG_FAIL = "PERIOD_ONLINE_CONFIG_FAIL";
    /* 逃生表上次更新成功的更新周期 */
    public static final String KEY_PERIOD_ESCAPE_SUCCESS = "PERIOD_BLACK_DATA_SUCCESS";
    /* 逃生表上次更新失败的更新周期 */
    public static final String KEY_PERIOD_ESCAPE_FAIL = "PERIOD_BLACK_DATA_FAIL";

    /* 白名单上次更新成功的更新周期 */
    public static final String KEY_PERIOD_WHITE_SUCCESS = "PERIOD_WHITE_DATA_SUCCESS";
    /* 白名单上次更新失败的更新周期 */
    public static final String KEY_PERIOD_WHITE_FAIL = "PERIOD_WHITE_DATA_FAIL";

    public static final int DEFAULT_PERIOD = 10 * 1000;

    /* 白名单上次更新的最新版本 */
    public static final String FLAG_WHITE_LIST_LAST_VERSION = "white_list_last_version";
    /* 黑名单上次更新的最新版本 */
    public static final String FLAG_BLACK_LIST_LAST_VERSION = "black_list_last_version";
    /* 配置表上次更新的最新版本 */
    public static final String FLAG_CONFIG_LIST_LAST_VERSION = "config_list_last_version";


    public static final int STATUS_SUCCESS = 1;
    public static final int STATUS_FAIL = 2;

    private int id;
    private String key;
    private String value;
    private String extend;
    private String version;
    private long lastUpdateTime;
    private int lastUpdateStatus;


    public OnlineConfigItem() {
    }

    public OnlineConfigItem(String key) {
        this.key = key;
        this.version = "0";
        // ensure to update at first time
        this.lastUpdateTime = 0L;
    }

    // TODO: content values construct
    public ContentValues getContentValues() {
        ContentValues values = new ContentValues();

        values.put(OnlineConfigDb.KEY_MAP_KEY, this.key);
        values.put(OnlineConfigDb.KEY_MAP_VALUE, this.value);
        values.put(OnlineConfigDb.KEY_EXTEND, this.extend);
        values.put(OnlineConfigDb.KEY_VERSION, this.version);
        values.put(OnlineConfigDb.KEY_LAST_UPDATE_TIME, this.lastUpdateTime);
        values.put(OnlineConfigDb.KEY_LAST_UPDATE_STATUS, this.lastUpdateStatus);
        return values;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(" key:" + this.key);
        sb.append(" value:" + this.value);
        sb.append(" version:" + this.version);
        return sb.toString();
    }

    public long getLastUpdateTime() {
        return lastUpdateTime;
    }

    public OnlineConfigItem setLastUpdateTime(long lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime;
        return this;
    }

    public int getLastUpdateStatus() {
        return lastUpdateStatus;
    }

    public OnlineConfigItem setLastUpdateStatus(int lastUpdateStatus) {
        this.lastUpdateStatus = lastUpdateStatus;
        return this;
    }

    public int getId() {
        return id;
    }

    public String getKey() {
        return key;
    }

    public OnlineConfigItem setKey(String key) {
        this.key = key;
        return this;
    }

    public String getValue() {
        return value;
    }

    public OnlineConfigItem setValue(String value) {
        this.value = value;
        return this;
    }

    public String getExtend() {
        return extend;
    }

    public OnlineConfigItem setExtend(String extend) {
        this.extend = extend;
        return this;
    }

    public String getVersion() {
        return version;
    }

    public OnlineConfigItem setVersion(String version) {
        this.version = version;
        return this;
    }

    public void setId(int id) {
        this.id = id;
    }
}
